﻿<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="../../../css/common.css">
    <link rel="stylesheet" href="../../../css/main.css">
    <script type="text/javascript" src="../../../js/jquery.min.js"></script>
    <script type="text/javascript" src="../../../js/colResizable-1.3.min.js"></script>
    <script type="text/javascript" src="../../../js/common.js"></script>

    <script type="text/javascript">
        function del(){
            confirm("确认删除");
        }
        function delall(){
            confirm("确认删除");
        }
        function excel(){
            confirm("确认导出");
        }
    </script>
</head>
<body>
<form action="/resource/wendang/demo1/list" method="post">
    <div id="search_bar" class="mt10">
        <div class="box">
            <div class="box_border">
                <div class="box_top"><b class="pl15">文档列表</b></div>
                <div class="box_center pt10 pb10">
                    <table class="form_table" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td>文件名称</td>
                            <td><input type="text" name="wordName" value="${wordName}" class="input-text lh25" size="10"></td>


                            <td><input type="submit" name="button" class="btn btn82 btn_search" value="查询">
                                <input type="reset" name="button" class="btn btn82 btn_recycle" value="清空"></td>
                        </tr>

                    </table>
                </div>

                <div  class="box_bottom pb5 pt5 pr10" style="border-top:1px solid #dadada;">
                    <div class="search_bar_btn" style="text-align:center;" >
                        <a href="/tiaozhuangwenjianjia" class="ext_btn"><span class="add"></span>添加文件夹</a>
                        <a href="/tiaozhuangwenjian" class="ext_btn"><span class="add"></span>添加文件</a>
                    </div>
                </div>
            </div>  </div>
</form>

<div id="table" class="mt10">
    <div class="box span10 oh">
        <form action="/bathcaozuo" method="post">
            <input type="hidden" name="method" id="mymethod">
            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table">
                <tr>
                    <th> <input type="checkbox" id="btn1"></th>
                    <th >名称</th>
                    <th >类型</th>
                    <th >创建人</th>
                    <th>创建时间</th>
<#--                    <th>操作</th>-->
                </tr>

                <#list  allWord.list  as  all>

                    <tr class="tr" align="center">
                        <td class="td_center"><input type="checkbox" name="arr" value="${all.wordId}"></td>
                        <td><span style="color: blue; cursor: pointer" id="wordfirst" onclick="f(${all.wordSupId},${all.wordId})">${all.wordName}</span></td>
                        <td><span id="wordType">${all.wordType}</span></td>
                        <td><span id="userName">${all.userName}</span></td>
                        <td><spqn id="wordTime">${all.wordTime?datetime}</spqn></td>
<#--                        <td>-->
<#--                            <a href="edit.html">编辑</a> |&nbsp;-->
<#--                            <a href="javascript:void(0)" onclick="del()">删除</a>-->
<#--                        </td>-->
                    </tr>
                <#--                        <ul>-->
                <#--                            <li>-->
                <#--                                <#list  all.word  as  al>-->
                <#--                                    <tr class="tr" align="center">-->
                <#--                                        <td class="td_center"><input type="checkbox"></td>-->
                <#--                                        <td><span style="color: blue; cursor: pointer" id="wordfirst" onclick="f(${al.wordSupId},${al.wordId})">${all.wordName}</span></td>-->
                <#--                                        <td><span id="wordType">${al.wordType}</span></td>-->
                <#--                                        <td><span id="userName">${al.userName}</span></td>-->
                <#--                                        <td><spqn id="wordTime">${al.wordTime?datetime}</spqn></td>-->
                <#--                                        <td>-->
                <#--                                            <a href="edit.html">编辑</a> |&nbsp;-->
                <#--                                            <a href="javascript:void(0)" onclick="del()">删除</a>-->
                <#--                                        </td>-->
                <#--                                    </tr>-->
                <#--                                </#list>-->
                <#--                            </li>-->
                <#--                        </ul>-->
                </#list>
                <tr>
                    <td colspan="2"><input type="button" name="button" class="btn btn82 btn_del" value="删除" onclick="tosub()">
                        <input type="button" name="button"  class="btn btn82 btn_export" value="导出" onclick="todaochu()">
                    </td>
                    <td colspan="5" align="right">
                        <div class="page mt10">
                            <div class="pagination">
                                <ul >
                                    <li class="first-child"><a href="/resource/wendang/demo1/list?page=1&wordName=${wordName}">首页</a></li>

                                    <li><a href="/resource/wendang/demo1/list?page=${(allWord.prePage==0)?string('1','${allWord.prePage}')}&wordName=${wordName}">上一页</a></li>
                                    <li class=""><a href="/resource/wendang/demo1/list?page=${(allWord.nextPage==0)?string('${allWord.pages}','${allWord.nextPage}')}&wordName=${wordName}">下一页</a></li>
                                    <li ><a href="/resource/wendang/demo1/list?page=${allWord.pages}&wordName=${wordName}">末页</a></li>
                                    <li ><span>共${allWord.total}条数据</span></li>
                                    <li ><span>共${allWord.getPages()}页</span></li>
                                </ul>
                            </div>
                        </div>
                    </td>
                </tr>
            </table>
            <div id="second" class="box span10 oh"></div>
<#--            <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table">-->
<#--                -->
<#--                <span id="second"></span>-->
<#--&lt;#&ndash;                <tr class="tr" align="center"></tr>&ndash;&gt;-->
<#--            </table>-->
        </form>
    </div>
</div>

</body>

<script type="text/javascript">

    function f(wordSupId,wordId){
        // alert(wordSupId);
        // alert(wordId);
        $.ajax({
            url:"/wendang/demo1/wordName",
            data:{wordSupId:wordSupId,wordId:wordId},
            type:"post",
            dataType:"json",
            success:function(rs){
                if(rs==null){
                    alert("当前文件夹没有文件！")
                    return;
                }
            // <tr><th>名称</th><th>名称</th><th>类型</th><th>创建人</th><th>创建时间</th></tr>
                 var str ="<table width='100%' border='0' cellpadding='0' cellspacing='0' class='list_table'>";
                for(var i=0;i<rs.length;i++){
                    str=str+"<tr class='tr' align='center'><td class='td_center'><input type='checkbox' name='arr' value='"+rs[i].wordId+"'></td><td>"+rs[i].wordName+"</td><td>"+rs[i].wordType+"</td><td>"+rs[i].userName+"</td><td>"+rs[i].wordTime+"</td></tr>";
                }
                str=str+"</table>";
                $("#second").html(str);

                // $("#wordfirst").html(rs.wordName);
                // $("#wordType").html(rs.wordType);
                // $("#userName").html(rs.userName);
                // $("#wordTime").html(rs.wordTime);
            }
        })
    }

    $(function(){
        $("#btn1").click(function(){
            //1.得到点击按钮的状态  checked 属于js对象中的属性
            //jquery->js
            var state=$(this)[0].checked;
            //alert(state);
            //2.设置全选
            var cks=document.getElementsByName("arr");
            for(var i=0;i<cks.length;i++){
                cks[i].checked=state;
            }
        });
    })

    //提交删除
    function  tosub() {

        document.getElementById("mymethod").value="delete";
        document.forms[1].submit();
    }

    //提交导出
    function todaochu(){
        //设置隐藏域的值
        document.getElementById("mymethod").value="daochu";
        //提交表单
        //  document.getElementById("myform").submit();
        document.forms[1].submit();
    }
    // $(function () {
    //     $("[name='wordsecond']").click(function (){
    //
    //     })
    // })
</script>
</html>